<?php
include("../utility/connection.php");
include("../model/mPaper.php");

include("../model/mUser.php");
session_start();

if($_SERVER["REQUEST_METHOD"] == "POST") {
    // detil file
    $speakerId = trim(mysql_real_escape_string($_POST["hidIdPembicara"]));
    $result = fnSelectSpeaker($speakerId);
    $count = mysql_num_rows($result); // number of row
    $speakerResult = mysql_fetch_array($result);
    
    // detil pembicara
    $userId = trim(mysql_real_escape_string($_POST["hidIdPembicara"]));
    $results = fnSelectUser($userId);
    $count1 = mysql_num_rows($results); // number of row
    $userResult = mysql_fetch_array($results);
    
    if ($count == 1) {
        $_SESSION['speakerId']=$speakerId;
        $_SESSION['speakerResult']=$speakerResult;
        
        if ($count1 == 1) {
            $_SESSION['userId']=$userId;
            $_SESSION['userResult']=$userResult;
        } else {
            $_SESSION['userId']=$userId;
            unset($_SESSION['userResult']);
        }
        
        header("location: ../ui/reviewer/review.php");
    } else {
        $_SESSION['speakerId']=$speakerId;
        unset($_SESSION['speakerResult']);
        
        if ($count1 == 1) {
            $_SESSION['userId']=$userId;
            $_SESSION['userResult']=$userResult;
        } else {
            $_SESSION['userId']=$userId;
            unset($_SESSION['userResult']);
        }
        
        header("location: ../ui/reviewer/review.php");
    }
}
?>